<?php

	if ( Session::isUserAuthenticated() ){
		Utils::redirect('home');
	}

?>
<form id="login-Utils" action="auth.php?_=checklogin" method="POST">
		
	<h1 style="text-align:left;">
		<span style="color:#0040e0;">G</span>
		<span style="color:#e02040;">o</span>
		<span style="color:#f0a000;">o</span>
		<span style="color:#0040e0;">g</span>
		<span style="color:#00a020;">l</span>
		<span style="color:#e02040;">e</span>
		<i><span style="color:brown">CoffeeMate&trade;</span></i>
	</h1>
	<hr/>
	
	<?php
		
		$message = Session::showLastFeedback();
		if ($message === '')
		{
				Session::set('feedback', array('type'=>'info', 
												'message'=>'Welcome', 
												'description' => 'Please use your phone number and password to log in.'));
				$message = Session::showLastFeedback();
		}
		echo $message;
	
	?>
	
	<label for="phone">Phone number<em>*</em><br/>(ex: +33625485269)</label>
	<input <?php echo Utils::insertErrorCssClass('phone'); ?> type="phone" name="phone" placeholder="Enter your phone number" pattern="\+\d{11}" required />
	<?php if ( !Utils::checkField('phone') ) echo Utils::showErrorMessage('The phone number is required!'); ?>
	<br/>
	<label for="password">Password<em>*</em></label>
	<input <?php echo Utils::insertErrorCssClass('phone'); ?> type="password" name="password" placeholder="Enter your password" required />
	<?php if ( !Utils::checkField('phone') ) echo Utils::showErrorMessage('The password field is required!'); ?>

	<p class="button_container">
		<div id="keeploggedin">
			<input type="checkbox" name="remember" value="yes"/>
			<span>Keep me logged in</span>
		</div>
		<img src="img/icons/signin.png" class="button_icon"/><input class="button green" type="submit" name="submit" value="Enter" id="login"/>
	</p>
	<hr/>
	<div style="text-align:right;">
		<a href="auth.php?p=createaccount" title="Create a new Google Coffemate account" style="color:#4ea5cd; text-align:center;" >I am a new user, create my account!</a>
	</div>
</form>
